<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>Kinetis Bootloader Host: elftosb::EncoreBootImageReader Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="nxp_logo_small.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Kinetis Bootloader Host
   &#160;<span id="projectnumber">2.0.0</span>
   </div>
   <div id="projectbrief">Host Tools for Kinetis devices</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Introduction</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('classelftosb_1_1_encore_boot_image_reader.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#pub-types">Public Types</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="#pro-attribs">Protected Attributes</a> &#124;
<a href="classelftosb_1_1_encore_boot_image_reader-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">elftosb::EncoreBootImageReader Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Reads a Piano/Encore boot image from an input stream.  
 <a href="classelftosb_1_1_encore_boot_image_reader.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="_encore_boot_image_reader_8h_source.html">EncoreBootImageReader.h</a>&gt;</code></p>
<div id="dynsection-0" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-0-trigger" src="closed.png" alt="+"/> Collaboration diagram for elftosb::EncoreBootImageReader:</div>
<div id="dynsection-0-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-0-content" class="dyncontent" style="display:none;">
<div class="center"><iframe scrolling="no" frameborder="0" src="classelftosb_1_1_encore_boot_image_reader__coll__graph.svg" width="1206" height="340"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classelftosb_1_1_encore_boot_image_reader_1_1read__error.html">read_error</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Exception class used for error found while reading a boot image.  <a href="classelftosb_1_1_encore_boot_image_reader_1_1read__error.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-types"></a>
Public Types</h2></td></tr>
<tr class="memitem:a57b7000d9a8c4f0910d256d75f1ff4d8"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a57b7000d9a8c4f0910d256d75f1ff4d8"></a>
typedef std::vector&lt; <a class="el" href="classelftosb_1_1_encore_boot_image.html#structelftosb_1_1_encore_boot_image_1_1section__header__t">EncoreBootImage::section_header_t</a> &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#a57b7000d9a8c4f0910d256d75f1ff4d8">section_array_t</a></td></tr>
<tr class="memdesc:a57b7000d9a8c4f0910d256d75f1ff4d8"><td class="mdescLeft">&#160;</td><td class="mdescRight">An array of section headers. <br /></td></tr>
<tr class="separator:a57b7000d9a8c4f0910d256d75f1ff4d8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4109bf2f31263d4bebb2a44fa5d840c2"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a4109bf2f31263d4bebb2a44fa5d840c2"></a>
typedef std::vector&lt; <a class="el" href="classelftosb_1_1_encore_boot_image.html#structelftosb_1_1_encore_boot_image_1_1boot__command__t">EncoreBootImage::boot_command_t</a> &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#a4109bf2f31263d4bebb2a44fa5d840c2">boot_tag_array_t</a></td></tr>
<tr class="memdesc:a4109bf2f31263d4bebb2a44fa5d840c2"><td class="mdescLeft">&#160;</td><td class="mdescRight">An array of boot tags. <br /></td></tr>
<tr class="separator:a4109bf2f31263d4bebb2a44fa5d840c2"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:ad7fe16410dc6232cf4b005b533e745af"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ad7fe16410dc6232cf4b005b533e745af"></a>
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#ad7fe16410dc6232cf4b005b533e745af">EncoreBootImageReader</a> (std::istream &amp;stream)</td></tr>
<tr class="memdesc:ad7fe16410dc6232cf4b005b533e745af"><td class="mdescLeft">&#160;</td><td class="mdescRight">Default constructor. <br /></td></tr>
<tr class="separator:ad7fe16410dc6232cf4b005b533e745af"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3aada13c8e3271e3f81d69188b342d1a"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a3aada13c8e3271e3f81d69188b342d1a"></a>
virtual&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#a3aada13c8e3271e3f81d69188b342d1a">~EncoreBootImageReader</a> ()</td></tr>
<tr class="memdesc:a3aada13c8e3271e3f81d69188b342d1a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Destructor. <br /></td></tr>
<tr class="separator:a3aada13c8e3271e3f81d69188b342d1a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr><td colspan="2"><div class="groupHeader">Decryption key</div></td></tr>
<tr><td colspan="2"><div class="groupText"><p>These methods provide access to the Data Encryption Key (DEK). Normally the DEK is discovered using the <a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#a2215b736fcde5b7bc3bffdae5f8dd55c" title="Reads the key dictionary, if the image is encrypted. ">readKeyDictionary()</a> method. </p>
</div></td></tr>
<tr class="memitem:ab1ec5f1d81a990bdadb1bcca2a4b13d2"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ab1ec5f1d81a990bdadb1bcca2a4b13d2"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>setKey</b> (const <a class="el" href="class_a_e_s_key.html">AESKey</a>&lt; 128 &gt; &amp;key)</td></tr>
<tr class="separator:ab1ec5f1d81a990bdadb1bcca2a4b13d2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6c72c8e3a813316b7ac6443b97c32926"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a6c72c8e3a813316b7ac6443b97c32926"></a>
const <a class="el" href="class_a_e_s_key.html">AESKey</a>&lt; 128 &gt; &amp;&#160;</td><td class="memItemRight" valign="bottom"><b>getKey</b> () const </td></tr>
<tr class="separator:a6c72c8e3a813316b7ac6443b97c32926"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr><td colspan="2"><div class="groupHeader">Readers</div></td></tr>
<tr><td colspan="2"><div class="groupText"><p>This group of methods is responsible for reading and parsing different pieces and parts of the boot image file. </p>
</div></td></tr>
<tr class="memitem:a241c4775a57d7dde3fb6f01ea0882bb7"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#a241c4775a57d7dde3fb6f01ea0882bb7">readImageHeader</a> ()</td></tr>
<tr class="memdesc:a241c4775a57d7dde3fb6f01ea0882bb7"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reads the header from the image.  <a href="#a241c4775a57d7dde3fb6f01ea0882bb7">More...</a><br /></td></tr>
<tr class="separator:a241c4775a57d7dde3fb6f01ea0882bb7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a393cf18518c6283d9825b26927e21b8f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#a393cf18518c6283d9825b26927e21b8f">computeHeaderDigest</a> (sha1_digest_t &amp;digest)</td></tr>
<tr class="memdesc:a393cf18518c6283d9825b26927e21b8f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Computes the actual SHA-1 digest of the image header.  <a href="#a393cf18518c6283d9825b26927e21b8f">More...</a><br /></td></tr>
<tr class="separator:a393cf18518c6283d9825b26927e21b8f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad122e17dde6f6d471753454dd534f181"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#ad122e17dde6f6d471753454dd534f181">readImageDigest</a> ()</td></tr>
<tr class="memdesc:ad122e17dde6f6d471753454dd534f181"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reads the digest at the end of the image.  <a href="#ad122e17dde6f6d471753454dd534f181">More...</a><br /></td></tr>
<tr class="separator:ad122e17dde6f6d471753454dd534f181"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a39ba72de0ae476680054640d014e30ff"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#a39ba72de0ae476680054640d014e30ff">computeImageDigest</a> (sha1_digest_t &amp;digest)</td></tr>
<tr class="memdesc:a39ba72de0ae476680054640d014e30ff"><td class="mdescLeft">&#160;</td><td class="mdescRight">Run a SHA-1 digest over the entire image.  <a href="#a39ba72de0ae476680054640d014e30ff">More...</a><br /></td></tr>
<tr class="separator:a39ba72de0ae476680054640d014e30ff"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aaff4bdaab6ff40e5a2f416a10aa667d1"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#aaff4bdaab6ff40e5a2f416a10aa667d1">readSectionTable</a> ()</td></tr>
<tr class="memdesc:aaff4bdaab6ff40e5a2f416a10aa667d1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Read the plaintext section table entries.  <a href="#aaff4bdaab6ff40e5a2f416a10aa667d1">More...</a><br /></td></tr>
<tr class="separator:aaff4bdaab6ff40e5a2f416a10aa667d1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2215b736fcde5b7bc3bffdae5f8dd55c"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#a2215b736fcde5b7bc3bffdae5f8dd55c">readKeyDictionary</a> (const <a class="el" href="class_a_e_s_key.html">AESKey</a>&lt; 128 &gt; &amp;kek)</td></tr>
<tr class="memdesc:a2215b736fcde5b7bc3bffdae5f8dd55c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reads the key dictionary, if the image is encrypted.  <a href="#a2215b736fcde5b7bc3bffdae5f8dd55c">More...</a><br /></td></tr>
<tr class="separator:a2215b736fcde5b7bc3bffdae5f8dd55c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a60ba4e053fbc8b1b1504bec835edf9f2"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#a60ba4e053fbc8b1b1504bec835edf9f2">readBootTags</a> ()</td></tr>
<tr class="separator:a60ba4e053fbc8b1b1504bec835edf9f2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7910721b98e5f9f4481352ec5ef114c5"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classelftosb_1_1_encore_boot_image_1_1_section.html">EncoreBootImage::Section</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#a7910721b98e5f9f4481352ec5ef114c5">readSection</a> (unsigned index)</td></tr>
<tr class="separator:a7910721b98e5f9f4481352ec5ef114c5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr><td colspan="2"><div class="groupHeader">Accessors</div></td></tr>
<tr><td colspan="2"><div class="groupText"><p>Information retrieved with reader methods is accessible through these methods. </p>
</div></td></tr>
<tr class="memitem:a0457c752be30b64d0e961d94fc1f9e43"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#a0457c752be30b64d0e961d94fc1f9e43">isEncrypted</a> () const </td></tr>
<tr class="memdesc:a0457c752be30b64d0e961d94fc1f9e43"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns whether the image is encrypted or not.  <a href="#a0457c752be30b64d0e961d94fc1f9e43">More...</a><br /></td></tr>
<tr class="separator:a0457c752be30b64d0e961d94fc1f9e43"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a841c2cc66e7d1763a6d64f60fff82f25"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a841c2cc66e7d1763a6d64f60fff82f25"></a>
const <a class="el" href="classelftosb_1_1_encore_boot_image.html#structelftosb_1_1_encore_boot_image_1_1boot__image__header__t">EncoreBootImage::boot_image_header_t</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#a841c2cc66e7d1763a6d64f60fff82f25">getHeader</a> () const </td></tr>
<tr class="memdesc:a841c2cc66e7d1763a6d64f60fff82f25"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a reference to the image's header. <br /></td></tr>
<tr class="separator:a841c2cc66e7d1763a6d64f60fff82f25"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab3aefeb886c8118db3c678fe2f278b18"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ab3aefeb886c8118db3c678fe2f278b18"></a>
const sha1_digest_t &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#ab3aefeb886c8118db3c678fe2f278b18">getDigest</a> () const </td></tr>
<tr class="memdesc:ab3aefeb886c8118db3c678fe2f278b18"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a reference to the SHA-1 digest read from the image. <br /></td></tr>
<tr class="separator:ab3aefeb886c8118db3c678fe2f278b18"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1a37088cba56753d44e3d73ef03fcfea"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a1a37088cba56753d44e3d73ef03fcfea"></a>
const <a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#a57b7000d9a8c4f0910d256d75f1ff4d8">section_array_t</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#a1a37088cba56753d44e3d73ef03fcfea">getSections</a> () const </td></tr>
<tr class="memdesc:a1a37088cba56753d44e3d73ef03fcfea"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a reference to the STL container holding the section headers. <br /></td></tr>
<tr class="separator:a1a37088cba56753d44e3d73ef03fcfea"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1a461d1f0c4dc51e298e31dafc51f60e"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a1a461d1f0c4dc51e298e31dafc51f60e"></a>
const <a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#a4109bf2f31263d4bebb2a44fa5d840c2">boot_tag_array_t</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#a1a461d1f0c4dc51e298e31dafc51f60e">getBootTags</a> () const </td></tr>
<tr class="memdesc:a1a461d1f0c4dc51e298e31dafc51f60e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a reference to the STL container holding the boot tags. <br /></td></tr>
<tr class="separator:a1a461d1f0c4dc51e298e31dafc51f60e"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr class="memitem:aca218f39dbbc8505a5cfa3ce42f66854"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aca218f39dbbc8505a5cfa3ce42f66854"></a>
uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#aca218f39dbbc8505a5cfa3ce42f66854">calculateCommandChecksum</a> (<a class="el" href="classelftosb_1_1_encore_boot_image.html#structelftosb_1_1_encore_boot_image_1_1boot__command__t">EncoreBootImage::boot_command_t</a> &amp;header)</td></tr>
<tr class="memdesc:aca218f39dbbc8505a5cfa3ce42f66854"><td class="mdescLeft">&#160;</td><td class="mdescRight">Calculates the 8-bit checksum on a boot command header. <br /></td></tr>
<tr class="separator:aca218f39dbbc8505a5cfa3ce42f66854"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-attribs"></a>
Protected Attributes</h2></td></tr>
<tr class="memitem:adc53a887f7cd16089627efcdac7f9d47"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="adc53a887f7cd16089627efcdac7f9d47"></a>
std::istream &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#adc53a887f7cd16089627efcdac7f9d47">m_stream</a></td></tr>
<tr class="memdesc:adc53a887f7cd16089627efcdac7f9d47"><td class="mdescLeft">&#160;</td><td class="mdescRight">The input stream to read the image from. <br /></td></tr>
<tr class="separator:adc53a887f7cd16089627efcdac7f9d47"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af93b255e7ff6f1c91acc5263b94ae0a0"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="af93b255e7ff6f1c91acc5263b94ae0a0"></a>
<a class="el" href="class_a_e_s_key.html">AESKey</a>&lt; 128 &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#af93b255e7ff6f1c91acc5263b94ae0a0">m_dek</a></td></tr>
<tr class="memdesc:af93b255e7ff6f1c91acc5263b94ae0a0"><td class="mdescLeft">&#160;</td><td class="mdescRight">DEK (data encryption key) read from the key dictionary. <br /></td></tr>
<tr class="separator:af93b255e7ff6f1c91acc5263b94ae0a0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a54c6ab0a09a64da1e2c451b2d7e1fe37"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a54c6ab0a09a64da1e2c451b2d7e1fe37"></a>
<a class="el" href="classelftosb_1_1_encore_boot_image.html#structelftosb_1_1_encore_boot_image_1_1boot__image__header__t">EncoreBootImage::boot_image_header_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#a54c6ab0a09a64da1e2c451b2d7e1fe37">m_header</a></td></tr>
<tr class="memdesc:a54c6ab0a09a64da1e2c451b2d7e1fe37"><td class="mdescLeft">&#160;</td><td class="mdescRight">Header from the boot image. <br /></td></tr>
<tr class="separator:a54c6ab0a09a64da1e2c451b2d7e1fe37"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab110c1baaa3cc58a4754b75767fc89fb"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ab110c1baaa3cc58a4754b75767fc89fb"></a>
sha1_digest_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#ab110c1baaa3cc58a4754b75767fc89fb">m_digest</a></td></tr>
<tr class="memdesc:ab110c1baaa3cc58a4754b75767fc89fb"><td class="mdescLeft">&#160;</td><td class="mdescRight">SHA-1 digest as read from the image. <br /></td></tr>
<tr class="separator:ab110c1baaa3cc58a4754b75767fc89fb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aae56f7858856d7bd63e025abbb6114bb"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aae56f7858856d7bd63e025abbb6114bb"></a>
<a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#a57b7000d9a8c4f0910d256d75f1ff4d8">section_array_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#aae56f7858856d7bd63e025abbb6114bb">m_sections</a></td></tr>
<tr class="memdesc:aae56f7858856d7bd63e025abbb6114bb"><td class="mdescLeft">&#160;</td><td class="mdescRight">The section table. <br /></td></tr>
<tr class="separator:aae56f7858856d7bd63e025abbb6114bb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a15d540538f18fbab7bf6ebe6e2ec1467"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a15d540538f18fbab7bf6ebe6e2ec1467"></a>
<a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#a4109bf2f31263d4bebb2a44fa5d840c2">boot_tag_array_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#a15d540538f18fbab7bf6ebe6e2ec1467">m_bootTags</a></td></tr>
<tr class="memdesc:a15d540538f18fbab7bf6ebe6e2ec1467"><td class="mdescLeft">&#160;</td><td class="mdescRight">The array of boot tags read from the image. <br /></td></tr>
<tr class="separator:a15d540538f18fbab7bf6ebe6e2ec1467"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Reads a Piano/Encore boot image from an input stream. </p>
</div><h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="a393cf18518c6283d9825b26927e21b8f"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void EncoreBootImageReader::computeHeaderDigest </td>
          <td>(</td>
          <td class="paramtype">sha1_digest_t &amp;&#160;</td>
          <td class="paramname"><em>digest</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Computes the actual SHA-1 digest of the image header. </p>
<dl class="section pre"><dt>Precondition</dt><dd>The image header must have already been read with a call to <a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#a241c4775a57d7dde3fb6f01ea0882bb7" title="Reads the header from the image. ">readImageHeader()</a>. </dd></dl>

</div>
</div>
<a class="anchor" id="a39ba72de0ae476680054640d014e30ff"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void EncoreBootImageReader::computeImageDigest </td>
          <td>(</td>
          <td class="paramtype">sha1_digest_t &amp;&#160;</td>
          <td class="paramname"><em>digest</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Run a SHA-1 digest over the entire image. </p>
<dl class="section pre"><dt>Precondition</dt><dd>The image header must have already been read with a call to <a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#a241c4775a57d7dde3fb6f01ea0882bb7" title="Reads the header from the image. ">readImageHeader()</a>. </dd></dl>
<dl class="section post"><dt>Postcondition</dt><dd>The stream head is at the end of the image minus the last two cipher blocks. </dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">digest</td><td>Where to store the resulting digest. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="classelftosb_1_1_encore_boot_image_reader_1_1read__error.html" title="Exception class used for error found while reading a boot image. ">read_error</a></td><td>Thrown if the image header is invalid. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a0457c752be30b64d0e961d94fc1f9e43"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool elftosb::EncoreBootImageReader::isEncrypted </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Returns whether the image is encrypted or not. </p>
<dl class="section pre"><dt>Precondition</dt><dd>The header must have been read already. </dd></dl>

</div>
</div>
<a class="anchor" id="a60ba4e053fbc8b1b1504bec835edf9f2"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void EncoreBootImageReader::readBootTags </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Before the boot tag is added to the <a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#a15d540538f18fbab7bf6ebe6e2ec1467" title="The array of boot tags read from the image. ">m_bootTags</a> member, some basic checks are performed. The command tag field is checked to make sure it matches #ROM_TAG_CMD. And the checksum field is verified to be sure it's correct.</p>
<p>After the call to this method returns, the array of boot tags is accessible with the <a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#a1a461d1f0c4dc51e298e31dafc51f60e" title="Returns a reference to the STL container holding the boot tags. ">getBootTags()</a> method. The array is sorted in the order in which the boot tags appeared in the image.</p>
<dl class="section pre"><dt>Precondition</dt><dd>Image header must have been read. </dd>
<dd>
Key dictionary must have been read and a valid DEK found. </dd></dl>
<dl class="section post"><dt>Postcondition</dt><dd>The stream head is left pointing just after the last boot tag. </dd></dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="classelftosb_1_1_encore_boot_image_reader_1_1read__error.html" title="Exception class used for error found while reading a boot image. ">read_error</a></td><td>A failure to read the boot tag, or a failure on one of the consistency checks will cause this exception to be thrown. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ad122e17dde6f6d471753454dd534f181"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void EncoreBootImageReader::readImageDigest </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Reads the digest at the end of the image. </p>
<dl class="section pre"><dt>Precondition</dt><dd>The image header must have already been read. </dd>
<dd>
The DEK must have been found already. </dd></dl>
<dl class="section post"><dt>Postcondition</dt><dd>The stream head is at the end of the digest. </dd></dl>

</div>
</div>
<a class="anchor" id="a241c4775a57d7dde3fb6f01ea0882bb7"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void EncoreBootImageReader::readImageHeader </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Reads the header from the image. </p>
<dl class="section post"><dt>Postcondition</dt><dd>Stream head points to just after the image header. </dd></dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="classelftosb_1_1_encore_boot_image_reader_1_1read__error.html" title="Exception class used for error found while reading a boot image. ">read_error</a></td><td>Thrown if the image header is invalid. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a2215b736fcde5b7bc3bffdae5f8dd55c"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool EncoreBootImageReader::readKeyDictionary </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="class_a_e_s_key.html">AESKey</a>&lt; 128 &gt; &amp;&#160;</td>
          <td class="paramname"><em>kek</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Reads the key dictionary, if the image is encrypted. </p>
<p>Requires that an OTP key has been provided as the sole argument. Passing the key into this method lets the caller search the key dictionary for any number of keys and determine which are valid. If <em>kek</em> is found in the dictionary, the decrypted DEK is saved and true is returned. A result of false means that <em>kek</em> was not found.</p>
<dl class="section pre"><dt>Precondition</dt><dd>The image header and section table must have been read already. </dd></dl>
<dl class="section post"><dt>Postcondition</dt><dd>The stream head points somewhere inside the key dictionary, or just after it. </dd>
<dd>
If the search was successful, the <a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#af93b255e7ff6f1c91acc5263b94ae0a0" title="DEK (data encryption key) read from the key dictionary. ">m_dek</a> member will contain the decrypted session key. Otherwise <a class="el" href="classelftosb_1_1_encore_boot_image_reader.html#af93b255e7ff6f1c91acc5263b94ae0a0" title="DEK (data encryption key) read from the key dictionary. ">m_dek</a> is not modified. </dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">kek</td><td>Search for this KEK in the dictionary. </td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">true</td><td>The DEK was found and decrypted. True is also returned when the image is not encrypted at all. </td></tr>
    <tr><td class="paramname">false</td><td>No matching key entry was found. The image cannot be decrypted. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a7910721b98e5f9f4481352ec5ef114c5"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classelftosb_1_1_encore_boot_image_1_1_section.html">EncoreBootImage::Section</a> * EncoreBootImageReader::readSection </td>
          <td>(</td>
          <td class="paramtype">unsigned&#160;</td>
          <td class="paramname"><em>index</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">index</td><td>The index of the section to read.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section pre"><dt>Precondition</dt><dd>Both the image header and section table must have been read already before calling this method. </dd></dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="classelftosb_1_1_encore_boot_image_reader_1_1read__error.html" title="Exception class used for error found while reading a boot image. ">read_error</a></td><td>This exception is raised if the stream reports an error while trying to read from the section. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="aaff4bdaab6ff40e5a2f416a10aa667d1"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void EncoreBootImageReader::readSectionTable </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Read the plaintext section table entries. </p>
<dl class="section pre"><dt>Precondition</dt><dd>Image header must have been read before this method is called. </dd></dl>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="_encore_boot_image_reader_8h_source.html">EncoreBootImageReader.h</a></li>
<li>EncoreBootImageReader.cpp</li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><b>elftosb</b></li><li class="navelem"><a class="el" href="classelftosb_1_1_encore_boot_image_reader.html">EncoreBootImageReader</a></li>
    <li class="footer">Generated on Mon Mar 7 2016 16:49:52 for Kinetis Bootloader Host by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
  </ul>
</div>
</body>
</html>
